
<header class="header navbar bg-white shadow">

  <div class="pull-right offscreen-right btn-group tool-button">
    <a class="btn btn-primary navbar-btn" onclick="_selectOn()">确定</a>
  </div>
</header>
<section class="content-wrap bg-white">
  <div class=panel-body style="padding-top: 50px;">
    <div class="table-responsive no-border">
      <table id="datatable_select" class="table table-bordered table-striped mg-t datatable">
        <thead>
        <tr>
          <th>ID</th>
          <th>名称</th>
      </table>
    </div>
  </div>
</section>
<script language="JavaScript">
  var datatable_select;
  function initdatatable_select() {
    datatable_select = $('#datatable_select').DataTable({
      "dom": '<"toolbar">frtip',
      "searching":false,
      "processing": false,
      "serverSide": true,
      "select": true,
      "ordering": true,
      "language": {
        "url": "/assets/plugins/datatables/cn.json"
      },
      "ajax": {
        "url": "/store/brand/index",
        "type": "post",
        "data": function (d) {
        
        }
      },
      "order": [[0, "desc"]],
      "columns": [
        {"data": "id", "bSortable": true},
        {"data": "name", "bSortable": true}
      ]
    });
    datatable_select.on('click', 'tr', function () {
      $(this).toggleClass('selected');
    });
  }

  function _selectOn() {
    var chks = datatable_select.rows('.selected').data();
    if (chks.length > 0) {
      $("#dialogSelect").modal("hide");
      $("#brand").val(chks[0].name);
      $("#brand_id").val(chks[0].id);
      
    }else{
      Toast.warning("请先选择内容！");
    }
  }
  $(document).ready(function () {
    initdatatable_select();
  });

</script>
